package socket;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * URL常用方法
 * @author 12609
 *
 */
public class URLTest {
	
	public static void main(String[] args) throws MalformedURLException {
		URL immoc = new URL("http://www.imooc.com");
		
		URL url = new URL(immoc, "/index.html?username=tom&age=3#test");
		
		System.out.println("协议："+url.getProtocol());
		System.out.println("主机："+url.getHost());
		System.out.println("端口："+url.getPort());
		System.out.println("文件路径："+url.getPath());
		System.out.println("文件名："+url.getFile());
		System.out.println("相对路径（锚点后面的内容）："+url.getRef());
		System.out.println(url.getQuery());
	}

}
